package com.hyt.it.ogt.ykcj.common.enums.zs;

import com.hyt.check.ruler.Ruler;
import com.hyt.check.ruler.summary.ObjRuler;
import com.hyt.check.ruler.summary.StrRuler;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @Description: 证件类型：1-大陆居民身份证，2-港澳台身份证，3-护照
 * @Author: STARF
 * @CreateDate: 2022/06/24 15:28
 **/
@Getter
@AllArgsConstructor
public enum IdentificationType {
    NONE("0", "未知", ObjRuler.none()),
    IDCARD("1", "大陆居民身份证", StrRuler.idCard()),
    HONGKONGMACAOANDTAIWANIDCARD("2", "港澳台身份证", StrRuler.idCardGAT()),
    PASSPORT("3", "护照", StrRuler.idCardPassport());

    private String code;
    private String desc;
    private Ruler ruler;

    public static String getDescByCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (IdentificationType identificationType : IdentificationType.values()) {
            if (identificationType.getCode().equals(code)) {
                return identificationType.getDesc();
            }
        }
        return code;
    }

    public static Ruler getRulerByCode(String code) {
        for (IdentificationType identificationType : IdentificationType.values()) {
            if (identificationType.getCode().equals(code)) {
                return identificationType.getRuler();
            }
        }
        return NONE.getRuler();
    }

    public static Ruler getRulerByDesc(String desc) {
        for (IdentificationType identificationType : IdentificationType.values()) {
            if (identificationType.getDesc().equals(desc)) {
                return identificationType.getRuler();
            }
        }
        return NONE.getRuler();
    }
}
